package compile

import (
	"fmt"
	"strings"
)

type ErrorReporter interface {
	Report(err *Error)
}

type _defaultErrorReporter struct{}

func (self *_defaultErrorReporter) Report(err *Error) {
	details := err.Details
	var detailStr string

	if len(details) > 0 {
		detailStr = "\n" + strings.Join(details, ", ")
	}

	fmt.Printf("%s : %s%s\n", err.Type, err.Message, detailStr)
}

var DefaultErrorReporter = new(_defaultErrorReporter)
